var express = require("express");
const { addDemo, findAllDemo, updateDemo, deleteDemo } = require("../service/demoService");
var router = express.Router();
const { UnknownError } = require("../utils/error");

// 获取项目
router.get("/", async function(req, res, next) {
    res.send(await findAllDemo())
})

// 新增项目
router.post("/", async function(req, res, next) {
    res.send(await addDemo(req.body));
})

// 修改项目
router.put("/:id", async function(req, res, next) {
    res.send(await updateDemo(req.params.id, req.body));
})

// 删除项目
router.delete("/:id", async function(req, res, next) {
    res.send(await deleteDemo(req.params.id));
})

module.exports = router;